

$(function(){
	
	
	
	var phone = window.localStorage["phone"];
	$(".zxphone").text(phone);
	
	
	// 发送验证码
	$(".cathCode").click(function() {
		if (phone.length == 11) {
			if ($(".cathCode").hasClass("fsphone")) {
				$(".cathCode").removeClass("fsphone");
				$.ajax({
					url : requestUrl + "app/user/sendPhoneVerifyCode.do",
					type : "POST",
					data : {
						"phone" : window.localStorage["phone"],
						"verifyType" : 4
					},
					dataType : "JSON",
					success : function(json) {
						if (json.code == 0) {
							var i = 0;

							var timer = setInterval(function() {
								$(".cathCode").html(60 - i + "秒后重试");
								if (i == 60) {
									clearInterval(timer);
									$(".cathCode").html("获取验证码");
									$(".cathCode").addClass("fsphone");

								}
								i++;
							}, 1000);
							console.log(json.registerCode);
						} else {
							alert(json.message);
						}
					}
				})
			}
		} else {
			alert("手机号获取失败，请重新登录！");
		}
	})
	
	
	//注销
	$(".uppwdBtn").click(function(){
		if($(".code").val()!==""){
			$.confirm({
				  title: '提示',
				  text: '注销账户会清空所有的信息和数据，您是否确认注销',
				  onOK: function () {
						$.ajax({
							url : requestUrl + "app/user/delUserInfo.do",
							type : "POST",
							data : {
								"token" :window.sessionStorage["token"],
								"userPhone":window.localStorage["phone"],
								"verifyCode" : $(".code").val(),
								"userId":localStorage.userId
							},
							dataType : "JSON",
							success : function(json) {
								if (json.code == 0) {
									window.localStorage.clear();
									window.sessionStorage.clear();
									window.location.href="index.html"
								}else{
									alert(json.message);
								}
								}
						})
				  },
				  onCancel: function () {
					  $.closeModal();
				  }
				});
		}else{
			alert("验证码不能为空！")
		}
	})
})